import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
  path: '/',
  redirect: '/login'
},
{
  path: '/testApp',
  name: 'testApp',
  component: () =>
    import('@/views/testApp')
},
{
  path: '/login',
  name: 'login',
  component: () =>
    import('@/views/Login')
}, {
  path: '/forget',
  name: 'forget',
  component: () =>
    import('@/views/forget')
}, {
  path: '/verification',
  name: 'verification',
  component: () =>
    import('@/views/verification')
},
{
  path: '/info',
  name: 'info',
  meta: {
    title: '个人信息'
  },
  component: () =>
    import('@/views/userinfo')

},
{
  path: '/home',
  name: 'home',
  meta: {
    title: '首页'
  },
  component: () =>
    import('@/views/Home'),
  children: [{
    path: '/dataPlatform',
    name: 'dataPlatform',
    meta: {
      title: '数据看板'
    },
    component: () =>
      import('@/pages/dataPlatform')
  },
  {
    path: '/userManage',
    name: 'userManage',
    meta: {
      title: '用户管理'
    },
    redirect: '/userManage/main',
    component: () =>
      import('@/pages/userManage'),
    children: [{
      path: '/userManage/main',
      meta: {
        main: true,
        title: '用户管理'
      },
      component: () =>
        import('@/pages/userManage/main')
    },
    {
      path: '/userManage/main/detail',
      redirect: '/userManage/main/detail/detailMain',
      meta: {
        title: '用户信息'
      },
      component: () =>
        import('@/pages/userManage/detail'),
      children: [{
        path: '/userManage/main/detail/detailMain',
        meta: {
          secMain: true,
          title: '用户信息'
        },
        component: () =>
          import('@/pages/userManage/detailMain')
      }, {
        path: '/userManage/main/detail/address',
        meta: {
          title: '登录地点'
        },
        component: () =>
          import('@/pages/userManage/address')
      }, {
        path: '/userManage/main/detail/proposal',
        meta: {
          title: '用户建议'
        },
        component: () =>
          import('@/pages/userManage/proposal')
      }]
    }
    ]
  },
  {
    path: '/cfManage',
    name: 'cfManage',
    redirect: '/cfManagemain',
    meta: {
      title: '会议管理'
    },

    component: () =>
      import('@/pages/cfManage'),
    children: [{
      path: '/cfManagemain',
      name: 'cfManagemain',
      meta: {
        main: true,
        title: '会议管理'
      },
      component: () =>
        import('@/pages/cfManage/main')
    }, {
      path: '/cfManagedetail',
      name: 'cfManagedetail',
      redirect: '/cfManagedetailMain',
      meta: {
        title: '用户详情'
      },
      component: () =>
        import('@/pages/cfManage/detail'),
      children: [{
        path: '/cfManagedetailMain',
        name: 'cfManagedetailMain',
        meta: {
          secMain: true,
          title: '会议管理'
        },
        component: () =>
          import('@/pages/cfManage/detailMain')
      },
      {
        path: '/cfManagedetailFile',
        name: 'cfManagedetailFile',
        meta: {
          title: '参会文档'
        },
        component: () =>
          import('@/pages/cfManage/file')
      }, {
        path: '/cfManagedetailPeople',
        name: 'cfManagedetailPeople',
        meta: {
          title: '参会人'
        },
        component: () =>
          import('@/pages/cfManage/people')

      }
      ]
    }]

  },
  {
    path: '/fileManage',
    name: 'fileManage',
    meta: {
      title: '文件管理'
    },
    component: () =>
      import('@/pages/fileManage')
  },
  {
    path: '/feedback',
    name: 'feedback',
    meta: {
      title: '意见反馈'
    },
    redirect: '/feedbackmain',
    component: () =>
      import('@/pages/feedback'),
    children: [{
      path: '/feedbackdetail',
      name: 'detail',
      meta: {
        title: '意见详情'
      },
      component: () =>
        import('@/pages/feedback/detail')
    }, {
      path: '/feedbackmain',
      name: 'feedbackmain',
      meta: {
        main: true,
        title: '意见反馈'
      },
      component: () =>
        import('@/pages/feedback/main')
    }]

  },
  {
    path: '/serviceManage',
    name: 'serviceManage',
    component: () => import('@/pages/serviceManage'),
    meta: {
      fatherNav: 'serviceManage'
    },
    children: [{
      path: '/serviceManage/setting',
      name: 'serviceSetting',
      meta: {
        main: true,
        title: '服务器设置'
      },
      component: () => import('@/pages/serviceManage/serviceSetting')

    },
    {
      path: '/serviceManage/userSession',
      name: 'servUserSession',
      meta: {
        main: true,
        title: '用户协议'
      },
      component: () => import('@/pages/serviceManage/servUserSession')
    },
    {
      path: '/serviceManage/privSession',
      name: 'servPrivSession',
      meta: {
        main: true,
        title: '隐私协议'
      },
      component: () => import('@/pages/serviceManage/servPrivSession')
    },
    {
      path: '/serviceManage/appList',
      name: 'servAppList',
      redirect: '/serviceManage/appList/main',
      meta: {
        // main: true,
        title: '应用上架'
      },
      component: () => import('@/pages/serviceManage/servAppList'),
      children: [{
        path: '/serviceManage/appList/main',
        name: 'main',
        meta: {
          main: true,
          title: '应用上架'
        },

        component: () => import('@/pages/serviceManage/servAppList/main.vue')
      }, {
        path: '/serviceManage/appList/edit',
        name: 'edit',
        meta: {
          title: '编辑'
        },
        component: () => import('@/pages/serviceManage/servAppList/edit.vue')
      }]
    }
    ]
  },
  {
    path: '/systemManage',
    name: 'systemManage',
    component: () => import('@/pages/systemManage'),
    meta: {
      fatherNav: 'systemManage'
    },
    children: [{
      path: '/systemManage/userManager',
      name: 'sysUserManage',
      meta: {
        main: true,
        title: '系统用户管理'
      },
      component: () => import('@/pages/systemManage/systemUserManage')
    },
    {
      path: '/systemManage/managerLog',
      name: 'sysManagerLog',
      meta: {
        main: true,
        title: '管理员日志'
      },
      component: () => import('@/pages/systemManage/adminLog')

    },
    {
      path: '/systemManage/levelManage',
      name: 'sysLevelManage',
      meta: {
        // main: true,
        title: '职位管理'
      },
      redirect: '/systemManage/levelManage/main',
      component: () => import('@/pages/systemManage/positionManage'),
      children: [{
        path: '/systemManage/levelManage/main',
        name: 'sysLevelManageMain',
        meta: {
          main: true,
          // secMain: true,
          title: '职位管理'
        },
        component: () => import('@/pages/systemManage/positionManage/main')
      }, {
        path: '/systemManage/levelManage/add',
        name: 'add',
        meta: {
          // main: true,
          title: '添加'
        },
        component: () => import('@/pages/systemManage/positionManage/add')
      }, {
        path: '/systemManage/levelManage/edit',
        name: 'edit',
        meta: {
          // main: true,
          title: '编辑'
        },
        component: () => import('@/pages/systemManage/positionManage/edit')
      }]
    }
    ]
  }
  ]
}
]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  mode: 'history',
  // base: '/admin/',
  base: process.env.BASE_URL,
  routes
})

export default router
